<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

	<ui:composition template="/layout/masterLayout.xhtml">  	
		<ui:define name="content">
			<style>
			   .col1 {width:15%;}
			   .col2 {width:15%;}
			   .col3 {width:70%;}
			</style>		
	    	<h:form>
				<h:panelGrid columns="2">									
					<h:inputTextarea value="#{postBean.post}" cols="40" rows="4"/>
									
					<h:commandButton value="Post" action="#{postBean.doPost()}" />
				</h:panelGrid>
			</h:form>	
			<br/>
			<h:dataTable id="dataTable" value="#{boardBean.posts}" var="v" border="1" 
			  rows="40" width="100%" columnClasses="co1,col2,col3"> 
				<h:column >
					<f:facet name="header">Timestamp</f:facet>
					<h:outputLabel value="#{v.date}" >
						<f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss"  />
					</h:outputLabel>
				</h:column>
				<h:column>
					<f:facet name="header">E-mail</f:facet>
					<h:outputLabel value="#{v.email}"/>
				</h:column>					
				<h:column>
					<f:facet name="header">Post</f:facet>
					<h:outputText value="#{v.contents}" styleClass="preformatted"/>
				</h:column>					
			</h:dataTable>
			
			<h:form>
				<p:poll interval="8" listener="#{postBean.refresh()}" update=":dataTable" />
			</h:form>							
		</ui:define>			
	</ui:composition>		
</html>